package easyexcel.model;

import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.excel.annotation.format.NumberFormat;
import com.alibaba.excel.annotation.write.style.ContentStyle;
import easyexcel.converter.SexConverter;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.math.BigDecimal;
import java.util.Date;

@Data
@ToString
@AllArgsConstructor
@NoArgsConstructor  // 一定要有无参构造方法
@ExcelIgnoreUnannotated//
public class UserData {
  @ExcelProperty(index = 0, value = "姓名")
  private String username;
  @ExcelProperty(index = 1, value = "年龄")
  private int age;
  @DateTimeFormat("yyyy-MM-dd")
  @ExcelProperty(index = 2, value = "生日")
  private Date birthday;


  @ExcelProperty(value = "性别", converter = SexConverter.class)
  private Integer sex;

  @ExcelProperty(value = "体重KG")
  @NumberFormat("0.##") // 会以字符串形式生成单元格，要计算的列不推荐
  private BigDecimal weight;
  @ContentStyle(dataFormat = 2)
  private BigDecimal weight2;

}
